package com.example.itshome.impl;

import android.content.Context;
import android.graphics.Rect;
import android.util.TypedValue;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class ItemDecorationImpl extends RecyclerView.ItemDecoration {
    private Context context;
    private float horizontal;
    private float vertical;

    public ItemDecorationImpl(Context context ,float v,float h){
        this.context=context;
        horizontal=h;
        vertical=v;
    }
    @Override
    public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
        int intervalH = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,horizontal, context.getResources().getDisplayMetrics());
        int intervalV = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,vertical, context.getResources().getDisplayMetrics());
        outRect.left = intervalH/2;
        outRect.right =intervalH/2;
        outRect.bottom = intervalV;
    }
}
